/*    */ package com.zimbra.qa.unittest;
/*    */ 
/*    */ import com.zimbra.common.util.EmailUtil;
/*    */ import com.zimbra.cs.mime.Mime;
/*    */ import java.io.ByteArrayInputStream;
/*    */ import java.io.IOException;
/*    */ import junit.framework.TestCase;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class TestEmailUtil
/*    */   extends TestCase
/*    */ {
/*    */   public void testSplit()
/*    */   {
/* 36 */     assertNull(EmailUtil.getLocalPartAndDomain("foo"));
/* 37 */     assertNull(EmailUtil.getLocalPartAndDomain("foo@"));
/* 38 */     assertNull(EmailUtil.getLocalPartAndDomain("@foo"));
/*    */     
/* 40 */     String[] parts = EmailUtil.getLocalPartAndDomain("jspiccoli@example.zimbra.com");
/* 41 */     assertNotNull(parts);
/* 42 */     assertEquals("jspiccoli", parts[0]);
/* 43 */     assertEquals("example.zimbra.com", parts[1]);
/*    */   }
/*    */   
/*    */ 
/*    */ 
/*    */   public void testRfc822()
/*    */     throws Exception
/*    */   {
/* 51 */     assertTrue(isRfc822Message("Content-Type: text/plain"));
/* 52 */     assertFalse(isRfc822Message("Content-Type text/plain"));
/* 53 */     assertFalse(isRfc822Message("Content-Type\r\n  :text/plain"));
/*    */     
/*    */ 
/* 56 */     StringBuilder buf = new StringBuilder();
/* 57 */     for (int i = 1; i <= 998; i++) {
/* 58 */       buf.append("X");
/*    */     }
/* 60 */     buf.append(": Y");
/* 61 */     assertFalse(isRfc822Message(buf.toString()));
/*    */   }
/*    */   
/*    */ 
/*    */ 
/*    */ 
/*    */   public void testParseAddressHeader()
/*    */     throws Exception
/*    */   {
/* 70 */     Mime.parseAddressHeader("(Test) <djoe@zimbra.com>,djoe@zimbra.com (Test)");
/*    */   }
/*    */   
/*    */   private boolean isRfc822Message(String content) throws IOException
/*    */   {
/* 75 */     return EmailUtil.isRfc822Message(new ByteArrayInputStream(content.getBytes()));
/*    */   }
/*    */   
/*    */   public static void main(String[] args) throws Exception
/*    */   {
/* 80 */     TestUtil.runTest(TestEmailUtil.class);
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/qa/unittest/TestEmailUtil.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */